package com.cloud.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.cloud.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import javax.validation.constraints.Size;

/**
 * 通知表 sys_notice
 *
 * @author yzj
 */
@Data
@Schema(name = "通知对象", description = "系统管理")
@TableName("sys_notice")
public class SysNotice extends BaseEntity {

    @TableId(value = "notice_id", type = IdType.AUTO)
    private Long noticeId;

    @Schema(description = "系统编号")
    private String sysCode;

    @Schema(description = "发送类型（0系统 1短信 2微信 3邮件 4浙政钉）")
    private Integer sendType;

    @Schema(description = "公告类型（1通知 2公告 3任务 4预警）")
    private Integer noticeType;

    @Schema(description = "公告标题")
    private String noticeTitle;

    @Schema(description = "公告内容")
    private String noticeContent;

    @Schema(description = "图片地址")
    private String imageUrl;

    @Schema(description = "视频地址")
    private String videoUrl;

    @Schema(description = "其他地址")
    private String otherUrl;

    @Schema(description = "公告状态（0正常 1关闭）")
    private Integer status;

    @Schema(description = "部门ID")
    private Long deptId;

    @Schema(description = "外键ID")
    private String outerId;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "删除标识（0代表存在 1代表删除）", hidden = true)
    @TableField(value = "deleted", fill = FieldFill.INSERT)
    private Integer deleted;

    @Schema(description = "用户组[多个用,隔开]")
    @TableField(exist = false)
    private String userIds;

    @Schema(description = "用户阅读状态（0未读 1已读）")
    @TableField(exist = false)
    private Integer readStatus;

    @Schema(description = "角色组[多个用,隔开]")
    @TableField(exist = false)
    private String roleIds;

    @Schema(description = "发送类型名称", hidden = true)
    @TableField(exist = false)
    private String sendTypeName;

    @Schema(description = "公告类型名称", hidden = true)
    @TableField(exist = false)
    private String noticeTypeName;

    @Schema(description = "部门组[多个用,隔开]")
    @TableField(exist = false)
    public String deptIds;

    @Schema(description = "用户主键", hidden = true)
    @TableField(exist = false)
    private Long userId;

    @Schema(description = "通知数量统计", hidden = true)
    @TableField(exist = false)
    private Integer noticeCount;

    @NotBlank(message = "公告标题不能为空")
    @Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
    public String getNoticeTitle() {
        return noticeTitle;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("noticeId", getNoticeId())
                .append("noticeTitle", getNoticeTitle())
                .append("noticeType", getNoticeType())
                .append("noticeContent", getNoticeContent())
                .append("status", getStatus())
                .append("createBy", getCreateBy())
                .append("createTime", getCreateTime())
                .append("updateBy", getUpdateBy())
                .append("updateTime", getUpdateTime())
                .append("remark", getRemark())
                .toString();
    }
}
